////////////////////////////////////////////////////////////////////////////////////////////////////
/// Copyright (c) 2009 - 2010 RacoonStudios
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy of this
/// software and associated documentation files (the "Software"), to deal in the Software
/// without restriction, including without limitation the rights to use, copy, modify, merge,
/// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
/// to whom the Software is furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in all copies or
/// substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
/// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
/// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
/// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
/// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
/// DEALINGS IN THE SOFTWARE.
////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once 
#ifndef assignmentlist_h__
#define assignmentlist_h__

#include "core/singleton.h"
#include "helper/array.h"
#include "iosystem/assignment.h"
#include "iosystem/filesystem.h"

namespace IO
{

	////////////////////////////////////////////////////////////////////////////////////////////////////
	///	\class	AssignmentList
	///
	///	\brief	
	///
	///	\date	2010/03/06
	/// \author	khaos                                                            
	////////////////////////////////////////////////////////////////////////////////////////////////////
	class AssignmentList
	{
		RE_DeclareSingleton(IO::AssignmentList);

		public:

			////////////////////////////////////////////////////////////////////////////////////////////////////
			///	\fn		static void Setup()
			///
			///	\brief	Sets all standard scheme's up.
			///
			///	\date	2010/03/06
			///	\author	khaos
			////////////////////////////////////////////////////////////////////////////////////////////////////
			static void Setup();



			////////////////////////////////////////////////////////////////////////////////////////////////////
			///	\fn		AssignmentList()
			///
			///	\brief	Constructor.
			///
			///	\date	2010/03/06
			///	\author	khaos
			////////////////////////////////////////////////////////////////////////////////////////////////////
			AssignmentList();

			////////////////////////////////////////////////////////////////////////////////////////////////////
			///	\fn		~AssignmentList()
			///
			///	\brief	Destructor.
			///
			///	\date	2010/03/06
			///	\author	khaos
			////////////////////////////////////////////////////////////////////////////////////////////////////
			~AssignmentList();




			bool ContainsAssignment(const Helper::String & scheme) const;




			////////////////////////////////////////////////////////////////////////////////////////////////////
			///	\fn		void Add(const Assignment & element)
			///
			///	\brief	Adds an Assignment to the list.
			///
			///	\date	2010/03/07
			///	\author	khaos
			///
			/// \param	[in]	element	The element we want to add to the list.
			////////////////////////////////////////////////////////////////////////////////////////////////////
			void Add(const Assignment & element);

			////////////////////////////////////////////////////////////////////////////////////////////////////
			///	\fn		const Assignment & AssignmentAtIndex(tIndex index) const 
			///
			///	\brief	Returns the Assignment of the specified index if the index is within
			///			the borders of the Array. Otherwise NULL will be returned.
			///
			///	\date	2010/03/07
			///	\author	khaos   
			///
			/// \param	[in]	index	The position of the Assignment we want.
			///
			///	\return	The Assignment we want.
			////////////////////////////////////////////////////////////////////////////////////////////////////
			const Assignment & AssignmentAtIndex(tIndex index) const;

			////////////////////////////////////////////////////////////////////////////////////////////////////
			///	\fn		const Helper::String & SchemeAtIndex(tIndex index) const
			///
			///	\brief	Returns the scheme of the Assignment if the specified index is within
			///			the borders of the Array. Otherwise InvalidIndex will be returned.
			///
			///	\date	2010/03/07
			///	\author	khaos   
			///
			/// \param	[in]	index	The position of the Assignment scheme we want.
			///
			///	\return	The scheme of the Assignment.
			////////////////////////////////////////////////////////////////////////////////////////////////////
			const Helper::String & SchemeAtIndex(tIndex index) const;

			////////////////////////////////////////////////////////////////////////////////////////////////////
			///	\fn		const Helper::String & PathAtIndex(tIndex index) const
			///
			///	\brief	Returns the path of the Assignment if the specified index is within
			///			the borders of the Array. Otherwise InvalidIndex will be returned.
			///
			///	\date	2010/03/07
			///	\author	khaos   
			///
			/// \param	[in]	index	The position of the Assignment path we want.
			///
			///	\return	The path of the Assignment.
			////////////////////////////////////////////////////////////////////////////////////////////////////
			const Helper::String & PathAtIndex(tIndex index) const;

			const Helper::String & Path(const Helper::String & str) const;



			void RemoveAssignment(const Helper::String & scheme);



			Helper::Array<Assignment> GetAllAssignments() const;

			const Helper::String ResolveAssignments(const Helper::String & str) const;

			IO::URI ResolveAssignments(const IO::URI & str) const;

		protected:

			Helper::Array<IO::Assignment> m_assigns;
			
		private:

	};

}

#endif // assignmentlist_h__